﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SPC.Properties;
using SPC.Classes;

namespace SPC
{
    public partial class settingsForm : Form
    {
        public settingsForm()
        {
            InitializeComponent();
        }

        private void settingsForm_Load(object sender, EventArgs e)
        {
            this.Text = Resources.settingsForm;
            
            settingsClass objSetting = new settingsClass();

            objSetting.PRINT_DOMAIN = Properties.Settings.Default.PRINT_DOMAIN;

            objSetting.PENALTY_PERCENT_VALUE = Properties.Settings.Default.PENALTY_PERCENT_VALUE.ToString();
            objSetting.PENALTY_DAY_COUNT_LIMIT = Properties.Settings.Default.PENALTY_DAY_COUNT_LIMIT.ToString();
            
            objSetting.PRINT_PENALTY_TITLE = Properties.Settings.Default.PRINT_PENALTY_TITLE;

            objSetting.PRINT_SUMMON_HEADER = Properties.Settings.Default.PRINT_SUMMON_HEADER;
            objSetting.PRINT_SUMMON_TITLE = Properties.Settings.Default.PRINT_SUMMON_TITLE;
            objSetting.PRINT_SUMMON_TO = Properties.Settings.Default.PRINT_SUMMON_TO;
            objSetting.PRINT_SUMMON_BODY = Properties.Settings.Default.PRINT_SUMMON_BODY;
            objSetting.PRINT_SUMMON_BODY_TOTALS_DETAILS = Properties.Settings.Default.PRINT_SUMMON_BODY_TOTALS_DETAILS;
            objSetting.PRINT_SUMMON_ADMIN = Properties.Settings.Default.PRINT_SUMMON_ADMIN;
            

            this.m_propertyGrid.SelectedObject = objSetting;
            this.m_propertyGrid.PropertyValueChanged += new PropertyValueChangedEventHandler(PropertyGrid1_PropertyValueChanged);
        }



        private void PropertyGrid1_PropertyValueChanged(Object sender, PropertyValueChangedEventArgs e)
        {
            switch (e.ChangedItem.Label)
            {
                //set { this["XXXXXXXXXXXX"] = value; }
                case "PENALTY_PERCENT_VALUE":
                    Properties.Settings.Default.PENALTY_PERCENT_VALUE = decimal.Parse(e.ChangedItem.Value.ToString());
                    Properties.Settings.Default.Save();
                    break;
                case "PENALTY_DAY_COUNT_LIMIT":
                    Properties.Settings.Default.PENALTY_DAY_COUNT_LIMIT = int.Parse(e.ChangedItem.Value.ToString());
                    Properties.Settings.Default.Save();
                    break;
                case "PRINT_PENALTY_TITLE":
                    Properties.Settings.Default.PRINT_PENALTY_TITLE = e.ChangedItem.Value.ToString();
                    Properties.Settings.Default.Save();
                    break;
                case "PRINT_DOMAIN":
                    Properties.Settings.Default.PRINT_DOMAIN = e.ChangedItem.Value.ToString();
                    Properties.Settings.Default.Save();
                    break;

                case "PRINT_SUMMON_TITLE":
                    Properties.Settings.Default.PRINT_SUMMON_TITLE = e.ChangedItem.Value.ToString();
                    Properties.Settings.Default.Save();
                    break;
                case "PRINT_SUMMON_HEADER":
                    Properties.Settings.Default.PRINT_SUMMON_HEADER = e.ChangedItem.Value.ToString();
                    Properties.Settings.Default.Save();
                    break;
                case "PRINT_SUMMON_BODY":
                    Properties.Settings.Default.PRINT_SUMMON_BODY = e.ChangedItem.Value.ToString();
                    Properties.Settings.Default.Save();
                    break;

                case "PRINT_SUMMON_TO":
                    Properties.Settings.Default.PRINT_SUMMON_TO = e.ChangedItem.Value.ToString();
                    Properties.Settings.Default.Save();
                    break;
                case "PRINT_SUMMON_ADMIN":
                    Properties.Settings.Default.PRINT_SUMMON_ADMIN = e.ChangedItem.Value.ToString();
                    Properties.Settings.Default.Save();
                    break;
                case "PRINT_SUMMON_BODY_TOTALS_DETAILS":
                    Properties.Settings.Default.PRINT_SUMMON_BODY_TOTALS_DETAILS = e.ChangedItem.Value.ToString();
                    Properties.Settings.Default.Save();
                    break;
            }
        }
    }
}
